from kafka import KafkaProducer


def send_message(topic, message):
    producer = KafkaProducer(
        bootstrap_servers='10.10.1.80:9092',
        value_serializer=lambda x: x.encode('utf-8')
    )
    try:
        producer.send(topic, value=message)
        producer.flush()
        print(f"Message sent to topic '{topic}': {message}")
    except Exception as e:
        print(f"Failed to send message: {e}")
    finally:
        producer.close()


if __name__ == "__main__":
    group_id = "drs02"
    topic_name = "DRS00001"
    message = "Hello, Kafka3333333!"
    send_message(topic_name, message)
